
<template>
    <div class="ChangeTable">
        <Row>
            <Col span="24">
                <Table
                    width="100%"
                    :columns="isSP ? contractTableHeadPartner : contractTableHead"
                    :data="contractTable.records"
                    :loading="loading"
                    border
                >
                    <template slot-scope="{ row, index }" slot="applyNo">
                        <a class="applyNo" @click="showContractDetial(row,'readOnly')">{{row.applyNo}}</a>
                    </template>
                    <!-- 处理状态 -->
                    <template slot-scope="{ row, index }" slot="processStatus">
                        <span>{{getTitle('processStatus',row.processStatus)}}</span>
                    </template>
                    <!-- 来源 -->
                    <template slot-scope="{ row, index }" slot="dataSource">
                        <span>{{getTitle('dataSource',row.dataSource)}}</span>
                    </template>
                </Table>
            </Col>
            <Col span="24">
                <Row type="flex" justify="end" class="table-page">
                    <Page
                        :current="contractTable.current"
                        :transfer="true"
                        :total="contractTable.total"
                        :page-size="contractTable.size"
                        @on-change="changePage"
                        @on-page-size-change="changePageSize"
                        :page-size-opts="pageSizeOpts"
                        size="small"
                        show-total
                        show-elevator
                        show-sizer
                    ></Page>
                </Row>
            </Col>
        </Row>
    </div>
</template>
<script>
import { getTitleFromDataDict } from "_p/basic/assets/contract/js/utils";

export default {
    props: {
        formValidate: {
            type: Object,
            required: true
        },
        dataDict: {
            type: Object,
            required: true
        },
        contractTable: {
            type: Object,
            required: true
        },
        loading: {
            type: Boolean,
            required: true,
            default: true
        },
        isSP: {
            type: Boolean,
            required: true,
            default: true
        }
    },
    data() {
        return {
            // loading: false,
            pageSizeOpts: [10, 20, 50, 100],
            contractTableHead: [
                {
                    title: "申请编号",
                    key: "applyNo",
                    slot: "applyNo",

                },
                {
                    title: "合同号",
                    key: "contractNo",
                },
                {
                    title: "客户姓名",
                    key: "custName",
                },
                {
                    title: "处理状态",
                    key: "processStatus",
                    slot: "processStatus"
                },
                {
                    title: "申请时间",
                    key: "applyDate",
                },

                {
                    title: "结束时间",
                    key: "endDate",
                },
                {
                    title: "来源",
                    key: "dataSource",
                    slot: "dataSource"
                }
            ],
            contractTableHeadPartner: [
                {
                    title: "申请编号",
                    key: "applyNo",
                    slot: "applyNo",
                },
                {
                    title: "客户姓名",
                    key: "custName",
                },
                {
                    title: "处理状态",
                    key: "processStatus",
                    slot: "processStatus"
                },
                {
                    title: "申请时间",
                    key: "applyDate",
                },
                {
                    title: "结束时间",
                    key: "endDate",
                }
            ]
        };
    },
    mounted() { },
    methods: {
        init() { },
        // 分页 Fn
        changePageSize(num) {
            this.$emit(
                "getList",
                Object.assign({}, this.formValidate, { pageSize: num })
            );
            this.formValidate.pageSize = num;
        },
        changePage(num) {
            this.$emit(
                "getList",
                Object.assign({}, this.formValidate, { pageNumber: num })
            );
            this.formValidate.pageNumber = num;
        },
        showContractDetial(row, readOnly) {
            this.$emit("showContractDetial", row, readOnly);
        },
        getTitle(type, val) {
            let data = this.dataDict[type + "Dict"] || [];
            return getTitleFromDataDict(data, val);
        }
    }
};
</script>
<style scoped>
</style>
